/******************************************************************************
* File description: OpenFileOthersFileAnalysis.qml
* Function: 打开：检测分析
* Current Version: 1.0.0
* Author: 张宇轩
* Date: 2024-08-31
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.14
import SvgImage 1.0

Item {
    id: root

    /* property 定义开始 */
    // 私有
    // AL
    property string alR2: "0" // R2
    property string alYIC: "0" // Y轴截距
    property string alEff: "0" // 效率
    property string alK: "0" // 斜率
    property bool alErr: false // 错误

    // AS
    property string asR2: "0" // R2
    property string asYIC: "0" // Y轴截距
    property string asEff: "0" // 效率
    property string asK: "0" // 斜率
    property bool asErr: false // 错误

    // Y
    property string yR2: "0" // R2
    property string yYIC: "0" // Y轴截距
    property string yEff: "0" // 效率
    property string yK: "0" // 斜率
    property bool yErr: false // 错误

    /* property 定义结束 */

    // 顶部导航栏
    TabbarNav {
        id: tabNav
        width: parent.width
        height: 56
        isEnable: true
        title: "检测分析"

        onReturnSig: {
            console.log("tabbar nav")
        }
        z: 999
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: 0

        // 主体部分
        Rectangle {
            id: mainPart
            Layout.fillWidth: true
            Layout.preferredHeight: parent.height - btnContainer.height
            Layout.alignment: Qt.AlignTop

            // 背景
            Rectangle {
                anchors.fill: parent
                LinearGradient {
                    anchors.fill: parent
                    start: Qt.point(0, 0)
                    end: Qt.point(0, height)
                    gradient: Gradient {
                        GradientStop {position: 0.0; color: "#007BD8"}
                        GradientStop {position: 1.0; color: "#001A5A"}
                    }
                }
            }

            Rectangle {
                id: mainContainer
                anchors {
                    fill: parent
                    topMargin: 16 + tabNav.height
                    bottomMargin: 16
                    leftMargin: 16
                    rightMargin: 16
                }
                color: "transparent"
                border.width: 0
                clip: true
                layer.enabled: true
                layer.effect: OpacityMask {
                    maskSource: Rectangle {
                        width: mainContainer.width
                        height: mainContainer.height
                        radius: 12
                    }
                }

                // 背景
                Rectangle {
                    anchors.fill: parent
                    color: "#FFc2def3"
                }

                // 主内容
                Item {
                    id: mainContent
                    anchors.fill: parent

                    Rectangle {
                        anchors.fill: parent
                        anchors.topMargin: 55 + 8
                        color: "#FFFFFFFF"
                        border.width: 0
                    }

                    ColumnLayout {
                        anchors.fill: parent

                        // 表格部分
                        Item {
                            id: tableContainer
                            Layout.fillWidth: true
                            Layout.fillHeight: true

                            // 表格分页
                            IndexTabWidget {
                                id: tablePageWidget
                                anchors.fill: parent
                            }
                        }

                        // 文字部分
                        Rectangle {
                            id: resultContainerBg
                            Layout.fillWidth: true
                            Layout.preferredHeight: resultGridLayout.height
                            color: "transparent"
                            border.width: 0

                            Item {
                                id: resultContainer
                                anchors {
                                    fill: parent
                                    bottomMargin: 5
                                    leftMargin: 20
                                    rightMargin: 20
                                }

                                GridLayout {
                                    id: resultGridLayout
                                    width: parent.width
                                    height: alCon.height + asCon.height + yCon.height
                                    columns: 2
                                    columnSpacing: 10
                                    rowSpacing: 0

                                    // AL
                                    Item {
                                        id: alCon
                                        Layout.fillWidth: true
                                        Layout.preferredHeight: alLayout.height

                                        ColumnLayout {
                                            id: alLayout
                                            width: parent.width
                                            height: al.height + alErr.height

                                            Label {
                                                id: al
                                                font {
                                                    family: 'Alibaba PuHuiTi'
                                                    pixelSize: 16
                                                }
                                                color: "#FF1677FF"
                                                text: `AL:R²:${alR2} Y轴截距:${alYIC} 扩散效率:${alEff} 斜率:${alK}`
                                            }

                                            Rectangle {
                                                id: alErrCon
                                                visible: alErr
                                                Layout.fillWidth: true
                                                Layout.preferredHeight: 28
                                                color: "#FFFDF6EC"

                                                // 图片
                                                Item {
                                                    id: alErrIcon
                                                    width: 16
                                                    height: 16
                                                    anchors {
                                                        left: parent.left
                                                        leftMargin: 16
                                                        verticalCenter: parent.verticalCenter
                                                    }

                                                    SvgImage {
                                                        anchors.fill: parent
                                                        antialiasing: true
                                                        source: "qrc:/icons/error.svg"
                                                    }
                                                }

                                                // 文字
                                                Label {
                                                    id: alErrText
                                                    anchors {
                                                        left: alErrIcon.right
                                                        verticalCenter: parent.verticalCenter
                                                    }
                                                    font {
                                                        family: "Alibaba PuHuiTi"
                                                        pixelSize: 16
                                                    }
                                                    color: "#FF666666"
                                                    text: qsTr("错误")
                                                    leftPadding: 10
                                                }
                                            }
                                        }
                                    }

                                    // AS
                                    Item {
                                        id: asCon
                                        Layout.fillWidth: true
                                        Layout.preferredHeight: asLayout.height

                                        ColumnLayout {
                                            id: asLayout
                                            width: parent.width
                                            height: as.height + asErr.height

                                            Label {
                                                id: as
                                                font {
                                                    family: 'Alibaba PuHuiTi'
                                                    pixelSize: 16
                                                }
                                                color: "#FF00C473"
                                                text: `AS:R²:${asR2} Y轴截距:${asYIC} 扩散效率:${asEff} 斜率:${asK}`
                                            }

                                            Rectangle {
                                                id: asErrCon
                                                visible: asErr
                                                Layout.fillWidth: true
                                                Layout.preferredHeight: 28
                                                color: "#FFFDF6EC"

                                                // 图片
                                                Item {
                                                    id: asErrIcon
                                                    width: 16
                                                    height: 16
                                                    anchors {
                                                        left: parent.left
                                                        leftMargin: 16
                                                        verticalCenter: parent.verticalCenter
                                                    }

                                                    SvgImage {
                                                        anchors.fill: parent
                                                        antialiasing: true
                                                        source: "qrc:/icons/error.svg"
                                                    }
                                                }

                                                // 文字
                                                Label {
                                                    id: asErrText
                                                    anchors {
                                                        left: asErrIcon.right
                                                        verticalCenter: parent.verticalCenter
                                                    }
                                                    font {
                                                        family: "Alibaba PuHuiTi"
                                                        pixelSize: 16
                                                    }
                                                    color: "#FF666666"
                                                    text: qsTr("错误")
                                                    leftPadding: 10
                                                }
                                            }
                                        }
                                    }

                                    // Y
                                    Item {
                                        id: yCon
                                        Layout.fillWidth: true
                                        Layout.preferredHeight: yLayout.height

                                        ColumnLayout {
                                            id: yLayout
                                            width: parent.width
                                            height: y.height + yErr.height

                                            Label {
                                                id: y
                                                font {
                                                    family: 'Alibaba PuHuiTi'
                                                    pixelSize: 16
                                                }
                                                color: "#FFFF2B37"
                                                text: `Y:R²:${yR2} Y轴截距:${yYIC} 扩散效率:${yEff} 斜率:${yK}`
                                            }

                                            Rectangle {
                                                id: yErrCon
                                                visible: yErr
                                                Layout.fillWidth: true
                                                Layout.preferredHeight: 28
                                                color: "#FFFDF6EC"

                                                // 图片
                                                Item {
                                                    id: yErrIcon
                                                    width: 16
                                                    height: 16
                                                    anchors {
                                                        left: parent.left
                                                        leftMargin: 16
                                                        verticalCenter: parent.verticalCenter
                                                    }

                                                    SvgImage {
                                                        anchors.fill: parent
                                                        antialiasing: true
                                                        source: "qrc:/icons/error.svg"
                                                    }
                                                }

                                                // 文字
                                                Label {
                                                    id: yErrText
                                                    anchors {
                                                        left: yErrIcon.right
                                                        verticalCenter: parent.verticalCenter
                                                    }
                                                    font {
                                                        family: "Alibaba PuHuiTi"
                                                        pixelSize: 16
                                                    }
                                                    color: "#FF666666"
                                                    text: qsTr("错误")
                                                    leftPadding: 10
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                }
            }
        }

        // 按钮部分
        Rectangle {
            id: btnContainer
            Layout.fillWidth: true
            Layout.preferredHeight: 80

            RowLayout {
                height: parent.height
                anchors.rightMargin: 16
                anchors.right: parent.right

                // 上传文件
                GradientButton {
                    id: upLoadBtn
                    gradText: "上传文件(U)"
                    onReleased: {
                    }
                }

                // 导出报告
                GradientButton {
                    id: exportBtn
                    gradText: "导出报告(E)"
                    onReleased: {
                    }
                }
            }
        }
    }
}
